package com.rustic.server.dto;

import cn.hutool.core.bean.BeanUtil;
import cn.xy.commons.enums.DataStatus;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.rustic.server.po.Attractions;
import com.rustic.server.dto.base.AttractionsBaseDTO;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * 表[attractions]对应AddDTO类
 *
 * @author auto
 */

@Data
@EqualsAndHashCode(callSuper = true)
public class AttractionsAddDTO extends AttractionsBaseDTO {
    /**
     * 关联乡村id
     */
    @NotNull(message = "关联乡村不能为空")
    @Min(value = 1, message = "关联乡村不能为空")
    @ApiModelProperty(value = "关联乡村id", dataType = "int")
    private int rusticId;

    /**
     * 景点名称
     */
    @NotEmpty(message = "景点名称不能为空")
    @Length(min = 0, max = 100, message = "景点名称长度为0-100个字符")
    @ApiModelProperty(value = "景点名称", dataType = "String")
    private String name;

    /**
     * 地址
     */
    @NotEmpty(message = "地址不能为空")
    @Length(min = 0, max = 500, message = "地址长度为0-500个字符")
    @ApiModelProperty(value = "地区", dataType = "String")
    private String address;

    /**
     * 详细地址
     */
    @Length(min = 0, max = 500, message = "详细地址长度为0-500个字符")
    @ApiModelProperty(value = "详细地址", dataType = "String")
    private String detailedAddress;

    /**
     * 介绍
     */
    @NotEmpty(message = "介绍不能为空")
    @ApiModelProperty(value = "介绍", dataType = "String")
    private String introduce;

    /**
     * 封面
     */
    @NotEmpty(message = "封面不能为空")
    @Length(min = 0, max = 500, message = "封面长度为0-500个字符")
    @ApiModelProperty(value = "封面", dataType = "String")
    private String cover;

    /**
     * 图片(轮播图)
     */
    @Length(min = 0, max = 500, message = "图片(轮播图)长度为0-500个字符")
    @ApiModelProperty(value = "图片(轮播图)", dataType = "String")
    private String images;

    /**
     * 景点等级id
     */
    @ApiModelProperty(value = "景点等级id", dataType = "int")
    private int grade;

    /**
     * 景点类型id
     */
    @NotNull(message = "景点类型不能为空")
    @Min(value = 1, message = "景点类型不能为空")
    @ApiModelProperty(value = "景点类型id", dataType = "int")
    private int type;

    /**
     * 排序
     */
    @Min(value = 0, message = "排序权重最小为0")
    @Max(value = 9999, message = "排序权重最大为9999")
    @ApiModelProperty(value = "排序", dataType = "int")
    private int sort;

    /**
     * 景点特色
     */
    @Length(min = 0, max = 200, message = "景点特色长度为0-200个字符")
    @ApiModelProperty(value = "景点特色", dataType = "String")
    private String feature;

    /**
     * 价格
     */
    @DecimalMin(value = "0.0", inclusive = true, message = "原价必须大于等于0")
    @ApiModelProperty(value = "价格", dataType = "BigDecimal")
    private BigDecimal price;

    public Attractions toAttractions() {
        Attractions attractions = new Attractions();
        BeanUtil.copyProperties(this, attractions);
        attractions.setDataStatus(DataStatus.NORMAL.getValue());
        return attractions;
    }
}
